﻿namespace MFGps.Data
{
    /// <summary>
    /// Struct contains the gps location information
    /// </summary>
    public struct DegreeTime
    {
        public static DegreeTime FromNmeaPos(string dec, string cardinal)
        {
            DegreeTime ret = new DegreeTime();
            if (dec.Length == 10)
            {
                ret.Degrees = int.Parse(dec.Substring(0, 2));
                ret.Minutes = int.Parse(dec.Substring(2, 2));
                ret.Seconds = double.Parse(dec.Substring(4, 4)) * 60;
            }
            else if (dec.Length == 9)
            {
                ret.Degrees = int.Parse(dec.Substring(0, 3));
                ret.Minutes = int.Parse(dec.Substring(3, 2));
                ret.Seconds = double.Parse(dec.Substring(5, 4)) * 60;
            }
            ret.Cardinal = cardinal;

            return ret;
        }

        /// <summary>
        /// The degree component of the value
        /// </summary>
        public int Degrees;

        /// <summary>
        /// The minute component of the value
        /// </summary>
        public int Minutes;

        /// <summary>
        /// The seconds component of the value with decimal precision
        /// </summary>
        public double Seconds;

        /// <summary>
        /// The compass cardinal compoent of the value
        /// </summary>
        public string Cardinal;

        /// <summary>
        /// Returns a representation object in string format
        /// </summary>
        public override string ToString()
        {
            throw new System.NotImplementedException();
        }

        /// <summary>
        /// Returns a representation of the object in string format that google maps will understand
        /// </summary>
        public string ToString(string type)
        {
            switch (type.ToUpper())
            {
                case "G":
                    throw new System.NotImplementedException();
                    //break;
                default:
                    return ToString();
            }
        }
    }
}
